#include <iostream>
#include <vector>
#include <map>

using namespace std;

// 2555. 两个线段获得的最多奖品
// https://leetcode.cn/problems/maximize-win-from-two-segments/description/

class Solution
{
public:
    int maximizeWin(vector<int> &prizePositions, int k)
    {
        int n = prizePositions.size();
        if (k * 2 + 1 >= prizePositions[n - 1] - prizePositions[0])
        {
            return n;
        }
        vector<int> mx(n + 1);
        int right = 0;
        int left = 0;
        int ans = 0;
        for (right = 0; right < n; right++)
        {
            while (prizePositions[right] - prizePositions[left] > k)
            {
                left++;
            }
            ans = max(ans, mx[right] + right - left + 1);
            mx[right + 1] = max(right - left + 1, mx[right]);
        }
        return ans;
    }
};

int main()
{
    return 0;
}